Uses routine,Process,DispProc;
var
	d:TDispatcherProcess;
	p:TProcess;
procedure proc_i;far;
var
	d:TDispatcherProcess;
	p:TProcess;
begin
	get_current_dispatcher(d);
	d.get_current_process(p);
	while true do;

end;
procedure proc_last;far;
var
	d:TDispatcherProcess;
	p:TProcess;
begin
	get_current_dispatcher(d);
	d.get_current_process(p);
	while true do
			if isEscape then
				d.stop;
end;
var
	
	i:word;
	a:array[1..255] of body_process;
	T:TProcess;
	nProcess:	word;
	Main:		descptr;
	beforeMem,
	afterMem:	longint;
begin
	beforeMem:=MemAvail;
	new(Main);
	writeln('enter the a number of process');
	readln(nProcess);
	for i:=1 to nProcess - 1 do a[i]:=proc_i;
	a[nProcess]:=proc_last;
	d.init(nProcess, a, Main);
	set_current_dispatcher(d);
	d.start;
	afterMem:=MemAvail;
	writeln('size of Memory before initialize: ', beforeMem);
	writeln('size of Memory before done: ', afterMem);
	d.done;
	dispose(Main);
	writeln('size of Memory after done: ', MemAvail);	
end.